package com.adteam.xmap.web;

import java.util.List;

import com.adteam.xmap.entity.Building;
import com.adteam.xmap.manager.BuildingManager;
import com.opensymphony.xwork2.ActionSupport;

public class BuildingAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	
	private BuildingManager buildingManager;

	private Building building;
	
	private List buildings;
	
	private Integer id;

	@Override
	public String execute() throws Exception {
		
		buildings = buildingManager.findAllBuildings();
		return "SUCCESS";
	}
	
	public String addInput() {
		
		return "add_input";
	}
	
	public String add() {
		
		buildingManager.addBuilding(building);
		return "add_success";
	}
	
	public String del() {
		
		buildingManager.delBuilding(id);
		return "del_success";
	}
	
	public String updateInput() {
		
		return "update_input";
	}
	
	public String update() {
		
		buildingManager.updateBuilding(building);
		return "update_success";
	}
	
	public String find() {
		
		building = buildingManager.findBuildingById(id);
		return "find_success";
	}

	public BuildingManager getBuildingManager() {
		return buildingManager;
	}

	public void setBuildingManager(BuildingManager buildingManager) {
		this.buildingManager = buildingManager;
	}

	public Building getBuilding() {
		return building;
	}

	public void setBuilding(Building building) {
		this.building = building;
	}

	public List getBuildings() {
		return buildings;
	}

	public void setBuildings(List buildings) {
		this.buildings = buildings;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
}
